package com.advertisementsystem.Mapper;

import com.advertisementsystem.entity.RolePermission;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RolePermissionMapper extends BaseMapper<RolePermission> {
    @Delete("DELETE FROM role_permission WHERE role_id = #{roleId}")
    void deleteByRoleId(Long roleId);

    @Insert({
            "<script>",
            "INSERT INTO role_permission (role_id, permission_id, created_time) VALUES ",
            "<foreach collection='list' item='item' separator=','>",
            "(#{item.roleId}, #{item.permissionId}, #{item.createdTime})",
            "</foreach>",
            "</script>"
    })
    void insertBatch(@Param("list") List<RolePermission> rolePermissions);
}